<div class="box-body">
    <form class="layui-form" action="{:url('/cha/express_include_attr/save')}" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">渠道</label>
            <div class="layui-input-block">
                <select name="channel_id" lay-search="">
                    <option value="">请选择</option>
                    {foreach $channel as $c}
                    <option value="{$c.channel_id}">{$c.channel_name}</option>
                    {/foreach}
                </select>
                <div class="layui-form-select">
                    <div class="layui-select-title">
                        <input type="text" placeholder="请选择" value="" class="layui-input">
                        <i class="layui-edge"></i>
                    </div>
                    <dl class="layui-anim layui-anim-upbit">
                        <dd lay-value="" class="layui-select-tips">请选择</dd>
                        {foreach $channel as $c}
                        <dd lay-value="{$c.channel_id}" class="">{$c.channel_name}</dd>
                        {/foreach}
                    </dl>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">可走SKU</label>
            <div class="layui-input-block">
                <div class="allow-select sku" name="include_sku" xm-select="">
                    <xm-select ua="win" size="medium" tabindex="1">
                        <input class="xm-select-default" lay-verify="" lay-vertype="" name="include_sku">
                        <i class="xm-icon"></i>
                        <div class="xm-tips">请选择</div>
                        <div class="xm-label single-row">
                            <div class="scroll">
                                <div class="label-content" title=""></div>
                            </div>
                        </div>
                        <div class="xm-body  absolute dis" style="top: 41.6562px; bottom: auto;">
                            <div tabindex="1" style="outline: none;">
                                <div>
                                    <div class="xm-search">
                                        <i class="xm-iconfont xm-icon-sousuo"></i>
                                        <input class="xm-input xm-search-input" placeholder="请选择">
                                    </div>
                                    <div class="scroll-body" style="max-height: 200px;">
                                        {if isset($express_attr)}
                                            <div class="xm-select-empty">有数据，带解析</div>
                                        {else}
                                            <div class="xm-select-empty">暂无数据</div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </xm-select>
                </div>
                <span class="layui-hide json-data"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">不可走SKU</label>
            <div class="layui-input-block">
                <div class="allow-select sku" name="exlude_sku" xm-select="">
                    <xm-select ua="win" size="medium" tabindex="1">
                        <input class="xm-select-default" lay-verify="" lay-vertype=""name="exlude_sku">
                        <i class="xm-icon"></i>
                        <div class="xm-tips">请选择</div>
                        <div class="xm-label single-row">
                            <div class="scroll">
                                <div class="label-content" title=""></div>
                            </div>
                        </div>
                        <div class="xm-body  absolute dis" style="top: 41.3498px; bottom: auto;">
                            <div tabindex="1" style="outline: none;">
                                <div>
                                    <div class="xm-search">
                                        <i class="xm-iconfont xm-icon-sousuo"></i>
                                        <input class="xm-input xm-search-input" placeholder="请选择">
                                    </div>
                                    <div class="scroll-body" style="max-height: 200px;">
                                        {if isset($express_attr)}
                                        <div class="xm-select-empty">有数据，带解析</div>
                                        {else}
                                        <div class="xm-select-empty">暂无数据</div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </xm-select>
                </div>
                <span class="layui-hide json-data"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">可走属性</label>
            <div class="layui-input-block">
                <div class="allow-select attr" name="include_attr" xm-select="">
                    <xm-select ua="win" size="medium" tabindex="1">
                        <input class="xm-select-default" lay-verify="" lay-vertype="" name="include_attr">
                        <i class="xm-icon"></i>
                        <div class="xm-tips">请选择</div>
                        <div class="xm-label single-row">
                            <div class="scroll">
                                <div class="label-content" title=""></div>
                            </div>
                        </div>
                        <div class="xm-body  absolute dis" style="top: 41.6562px; bottom: auto;">
                            <div tabindex="1" style="outline: none;">
                                <div>
                                    <div class="xm-search">
                                        <i class="xm-iconfont xm-icon-sousuo"></i>
                                        <input class="xm-input xm-search-input" placeholder="请选择">
                                    </div>
                                    <div class="scroll-body" style="max-height: 200px;">
                                        {if isset($express_attr)}
                                        <div class="xm-select-empty">有数据，带解析</div>
                                        {else}
                                        <div class="xm-select-empty">暂无数据</div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </xm-select>
                </div>
                <span class="layui-hide json-data"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">不可走属性</label>
            <div class="layui-input-block">
                <div class="allow-select attr" name="exlude_attr" xm-select="">
                    <xm-select ua="win" size="medium" tabindex="1">
                        <input class="xm-select-default" lay-verify="" lay-vertype="" name="exlude_attr">
                        <i class="xm-icon"></i>
                        <div class="xm-tips">请选择</div>
                        <div class="xm-label single-row">
                            <div class="scroll">
                                <div class="label-content" title=""></div>
                            </div>
                        </div>
                        <div class="xm-body  absolute dis" style="top: 41.5261px; bottom: auto;">
                            <div tabindex="1" style="outline: none;">
                                <div>
                                    <div class="xm-search">
                                        <i class="xm-iconfont xm-icon-sousuo"></i>
                                        <input class="xm-input xm-search-input" placeholder="请选择">
                                    </div>
                                    <div class="scroll-body" style="max-height: 200px;">
                                        {if isset($express_attr)}
                                        <div class="xm-select-empty">有数据，带解析</div>
                                        {else}
                                        <div class="xm-select-empty">暂无数据</div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </xm-select>
                </div>
                <span class="layui-hide json-data"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" placeholder="" name="remark" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="checkbox" name="status" value="1" checked="" lay-skin="switch">
                <div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch">
                    <em></em><i></i>
                </div>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    $(".allow-select").each(function () {
        var $this = $(this)
            , defVal = []
            , args = {}
            , jsonStr = $this.parent().find(".json-data").text().trim();
        if (jsonStr.length > 0) {
            var json = JSON.parse(jsonStr);
            for (let i in json) {
                if ($this.is(".sku")) {
                    defVal.push({
                        "id": {
                            key: "sku",
                            value: json[i].sku
                        },
                        "name": {
                            key: "sku",
                            value: json[i].sku
                        }
                    });
                } else if ($this.is(".attr")) {
                    defVal.push({
                        "id": {
                            key: "attr_id",
                            value: json[i].attr_id
                        },
                        "name": {
                            key: "attr_name",
                            value: json[i].attr_name
                        }
                    });
                }
            }
        }
        args["name"] = $this.attr("name");
        if ($this.is(".sku")) {
            args["prop"] = {
                "name": "sku",
                "value": "sku"
            };
            args["select"] = {
                "id": "sku",
                "name": "sku"
            };
            args["search"] = "sku";
            args["remoteUrl"] = "/wms/product/get.html";

        } else if ($this.is(".attr")) {
            args["prop"] = {
                "name": "attr_name",
                "value": "attr_id"
            };
            args["select"] = {
                "id": "attr_id",
                "name": "attr_name"
            };
            args["search"] = "code";
            args["remoteUrl"] = "/cha/attrs/get.html";
        }
        renderSearch(this, args, defVal);
    });
</script>
<span class="layui-layer-setwin">
    <a class="layui-layer-ico layui-layer-close layui-layer-close1" href="javascript:;"></a>
    </span>
<div class="layui-layer-btn layui-layer-btn-">
    <a class="layui-layer-btn0" lay-submit="">确定</a>
    <a class="layui-layer-btn1">取消</a>
</div>
<span class="layui-layer-resize"></span>
